package keshe;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Info implements Serializable {
    @Serial
    private static final long serialVersionUID = 4695134999693118352L;
    private int depositOrDraw;//存款为1，取款为-1
    private double money;
    private LocalDateTime time ;

    public void setTime(LocalDateTime time) {
        this.time = time;
    }

    public Info() {
    }

    public LocalDateTime getTime() {
        return time;
    }

    public Info(int depositOrDraw, double money, LocalDateTime time) {
        this.depositOrDraw = depositOrDraw;
        this.money = money;
        this.time = time;
    }
    public int getDepositOrDraw() {
        return depositOrDraw;
    }
    public void setDepositOrDraw(int depositOrDraw) {
        this.depositOrDraw = depositOrDraw;
    }


    public double getMoney() {
        return money;
    }


    public void setMoney(double money) {
        this.money = money;
    }


    public String soutTime() {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return (dateTimeFormatter.format(time));
    }


    public void setTime() {
        this.time=LocalDateTime.now();
    }

    public String toString() {
        if(depositOrDraw==1){
            return "存入金额：   "+money+"        时间：    "+soutTime();
        }else {
            return "取出金额：   "+money+"        时间：    "+soutTime();
        }
    }
}
